package Like;

import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.RandomUtils;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class AppTest {
    public static void main(String[] args) throws Exception{
        Class<Animal> A = Animal.class;
        Animal animal = A.newInstance();
        Field[] fields = A.getDeclaredFields();
        for (Field field:fields){
            field.setAccessible(true);
            Class<?> type = field.getType();
            if(type.isAssignableFrom(String.class)){
                String s= RandomStringUtils.randomAlphabetic(6);
                field.set(animal,s);
            }
            else if (type.isAssignableFrom(Double.class)){
                double w = RandomUtils.nextDouble();
                field.set(animal,w);
            }
        }
        System.out.println(animal.getName());
        System.out.println(animal.getWeight());
    }
}
